package org.example.sort;

//插入排序的算法
public class InsertionSort {
    public static void main(String[] args) {
        int[] arr = {10,15,97,15,64,75,0,23,78,62,197,2};
        for (int i = 1; i < arr.length; i++) {
            for (int j = i; j > 0; j--) {
                if (arr[j] < arr[j - 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j - 1];
                    arr[j - 1] = temp;
                }else {
                    break;
                }
            }
        }

        for (int i = 0; i <= arr.length -1; i++) {
            System.out.print(arr[i]+" ");
        }
    }
}
